package com.cy.controller;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Usefulness: 用途
 * @Author: LeiTing
 * @Date: 2021/9/17  14:06
 * @Version 1.0
 */
@Slf4j
@RefreshScope
@RestController
public class ProviderLogController {
//    private static final Logger log= LoggerFactory.getLogger(ProviderLogController.class);

    //此属性会在对象构建时初始化 注意是在对象创建时初始化 不是实时变化
    //服务启动时会将所有配置信息（配置文件或配置中心）读取到Environment对象
    //@Value用于告诉Spring从Environment对象中读取配置信息
    //将读取到的配置内容赋值给对象的属性
    @Value("${logging.level.com.cy:info}")
    private String loglevel;

    @GetMapping("/provider/doGetLoglevel")
    public String doGetLoglevel(){
        //日志级别：trace<debug<info<warn<error
        log.trace("==log.trace==");//跟踪
        log.debug("==log.debug==");//调试
        log.info("==log.info==");//常规信息
        log.warn("==log.warn==");//警告
        log.error("==log.error==");//错误信息
        return "log level is "+loglevel;
    }
}
